package com.ruoyi.app.controller;

import com.ruoyi.app.domain.Balance;
import com.ruoyi.app.service.BalanceService;
import com.ruoyi.app.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RequestMapping("balance")
@RestController
public class BalanceController {
    @Autowired
    BalanceService balanceService;

    /**
     * 查看患者余额
     * @param patientId
     * @return
     */

    @RequestMapping("balanceById")
    public Result balanceById(Integer patientId) {
        Balance balance = balanceService.balanceById(patientId);
        return Result.ok(balance);
    }

    /**
     * 充值
     */
    @RequestMapping("recharge")
    public Result recharge(@RequestParam("patientId") Integer patientId, @RequestParam("price") BigDecimal price) {
        balanceService.recharge(patientId, price);
        return Result.ok("充值成功");
    }
}
